from django.db import models
from tinymce.models import HTMLField
from db.base_model import BaseModel
# Create your models here.


class IndexTopCarousel(BaseModel):
    """首页顶部轮播图"""

    big_title = models.CharField(max_length=50,verbose_name='大标题')
    big_title_en = models.CharField(max_length=50,verbose_name='big_title_en')
    small_title = models.CharField(max_length=50,verbose_name='小标题')
    small_title_en = models.CharField(max_length=50,verbose_name='small_title_en')
    image = models.ImageField(upload_to='top_carousel',verbose_name='图片')
    index = models.SmallIntegerField(default=0,verbose_name='展示顺序')

    class Meta:
        db_table = 'df_top_carousel'
        verbose_name='首页--顶部轮播图'
        verbose_name_plural = verbose_name




class IndexBottomCarousel(BaseModel):
    """首页底部轮播图"""
    image = models.ImageField(upload_to='bottom_carousel',verbose_name='图片')
    index = models.SmallIntegerField(default=0,verbose_name='展示顺序')

    class Meta:
        db_table = 'df_bottom_carousel'
        verbose_name = '首页--底部轮播图'
        verbose_name_plural = verbose_name


class IndexNewsBanner(BaseModel):
    """首页新闻展示"""
    language_choices = (
        (0, 'en'),
        (1, 'cn'),
    )

    language = models.IntegerField(default=0,choices=language_choices,verbose_name='语言')
    title = models.CharField(max_length=50,verbose_name='新闻标题')
    image = models.ImageField(upload_to='news_banner',verbose_name='新闻图片')
    index = models.SmallIntegerField(default=0, verbose_name='展示顺序')
    content = HTMLField(blank=True,verbose_name='新闻正文')

    class Meta:
        db_table = 'df_news_banner'
        verbose_name = '首页--新闻展示'
        verbose_name_plural = verbose_name


class IndexVedioBanner(BaseModel):
    """首页视频展示"""
    title = models.CharField(max_length=50,verbose_name='标题')
    logo = models.ImageField(upload_to='vedio_banner',verbose_name='logo')
    image = models.ImageField(upload_to='vedio_banner',verbose_name='图片')
    vedio = models.FileField(upload_to='vedio_banner',verbose_name='视频')
    index = models.SmallIntegerField(default=0,verbose_name='展示顺序')

    class Meta:
        db_table = 'df_vedio_banner'
        verbose_name = '首页--视频展示'
        verbose_name_plural = verbose_name

class ReceiverEmail(BaseModel):
    """接收邮箱地址"""
    email = models.CharField(max_length=50,verbose_name='邮箱地址')


    class Meta:
        db_table = 'df_email'
        verbose_name = '首页--获取邮箱地址'
        verbose_name_plural = verbose_name





# 产品中心页模型类
class TopicType(BaseModel):
    """主题类型模型类"""
    topic = models.CharField(max_length=50,verbose_name='主题')
    topic_en = models.CharField(max_length=80, verbose_name='topic_en')
    desc = models.CharField(max_length=100,blank=True,verbose_name='简介')
    desc_en = models.CharField(max_length=200,blank=True, verbose_name='desc_en')
    background_image = models.ImageField(upload_to='topic',verbose_name='背景图片')
    index = models.SmallIntegerField(default=0,verbose_name='展示顺序')

    class Meta:
        db_table = 'df_topic_type'
        verbose_name = '产品中心--主题类型'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.topic



class Subtitle(BaseModel):
    """子标题模型类"""
    topic = models.ForeignKey('TopicType',verbose_name='主题')
    title = models.CharField(max_length=20,verbose_name='子标题名')
    title_en = models.CharField(max_length=40, verbose_name='title_en')
    logo = models.ImageField(upload_to='subtitle',verbose_name='logo')
    desc = models.CharField(max_length=100,blank=True,verbose_name='简介')
    desc_en = models.CharField(max_length=500,blank=True,verbose_name='desc_en')
    index = models.SmallIntegerField(default=0, verbose_name='展示顺序')

    class Meta:
        db_table = 'df_subtitle'
        verbose_name = '产品中心--子标题'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.title



class SubtitleImage(BaseModel):
    """子标题图片模型类"""
    subtitle = models.ForeignKey('Subtitle',verbose_name='子标题')
    image = models.ImageField(upload_to='subtitle',verbose_name='图片')
    index = models.SmallIntegerField(default=0, verbose_name='展示顺序')

    class Meta:
        db_table = 'df_subtitle_image'
        verbose_name = '产品中心--子标题图片'
        verbose_name_plural = verbose_name




class SubtitleVideo(BaseModel):
    """子标题视频模型类"""
    subtitle = models.ForeignKey('Subtitle',verbose_name='子标题')
    video = models.FileField(upload_to='subtitle',verbose_name='视频')
    index = models.SmallIntegerField(default=0, verbose_name='展示顺序')

    class Meta:
        db_table = 'df_subtitle_video'
        verbose_name = '产品中心--子标题视频'
        verbose_name_plural = verbose_name










